package cn.wolfcode;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.util.Collections;

public class CodeGenerator {
    public static void main(String[] args) {
        String url = "jdbc:mysql://localhost:3309/testai?useSSL=false&serverTimezone=GMT%2B8";
        String username = "root";
        String password = "123456";
//        String moduleName = "system";
        String[] tableNames = {"employee"}; // 要生成的表名

        FastAutoGenerator.create(url, username, password)
            .globalConfig(builder -> {
                builder.author("y") // 设置作者
                    .outputDir(System.getProperty("user.dir") + "/src/main/java") // 输出路径
                    .enableSwagger() // 开启swagger注解
                    .disableOpenDir(); // 禁止打开输出目录
            })
            .packageConfig(builder -> {
                builder.parent("cn.wolfcode");
            })
            .strategyConfig(builder -> {
                builder.addInclude(tableNames) // 包含的表
                    .entityBuilder() // 实体配置
                    .enableLombok() // 启用Lombok
                    .controllerBuilder() // 控制器配置
                    .enableRestStyle(); // 启用RestController
            })
            .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎
            .execute();
    }
}
